<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" th:with="title='发布文章',active='publish'">
<header th:replace="back/header::headerFragment(${title},${active})"></header>
<link th:href="@{/back/plugins/tagsinput/jquery.tagsinput.css}" rel="stylesheet"/>
<link th:href="@{/back/plugins/select2.dist.css/select2-bootstrap.css}" rel="stylesheet"/>
<link th:href="@{/back/plugins/toggles/toggles.css}" rel="stylesheet"/>

<link th:href="@{/back/plugins/mditor/css/mditor.min.css}" rel="stylesheet"/>
<link th:href="@{/back/plugins/dropzone/4.3.0/min/dropzone.min.css}" rel="stylesheet">

<link rel="stylesheet" href="/layui/css/layui.css">
<style>
    #tags_tagsinput {
        background-color: #fafafa;
        border: 1px solid #eeeeee;
    }

    #tags_addTag input {
        width: 100%;
    }

    #tags_addTag {
        margin-top: -5px;
    }

    .mditor .editor{
        font-size: 14px;
        font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
    }
    .mditor .backdrop, .mditor .textarea, .mditor .viewer{
        font-size: 14px;
    }
    .markdown-body{
        font-size: 14px;
    }
    .note-toolbar {
        text-align: center;
    }

    .note-editor.note-frame {
        border: none;
    }

    .note-editor .note-toolbar {
        background-color: #f5f5f5;
        padding-bottom: 10px;
    }

    .note-toolbar .note-btn-group {
        margin: 0;
    }

    .note-toolbar .note-btn {
        border: none;
    }

    #articleForm #dropzone {
        min-height: 200px;
        background-color: #dbdde0;
        line-height:200px;
        margin-bottom: 10px;
    }
    #articleForm .dropzone {
        border: 1px dashed #8662c6;
        border-radius: 5px;
        background: white;
    }
    #articleForm .dropzone .dz-message {
        font-weight: 400;
    }
    #articleForm .dropzone .dz-message .note {
        font-size: 0.8em;
        font-weight: 200;
        display: block;
        margin-top: 1.4rem;
    }
</style>
<body class="fixed-left">
<div th:replace="/client/header::header(null,null)" />
<div id="wrapper">
        <div class="content" style="margin-right: 50px">
            <div class="container">
                <div class="row">
                    <div class="col-sm-12">
                        <h2 class="page-title">
                            创建课程
                        </h2>
                        <hr style="height: 5px;background-color:pink"/>
                    </div>
                    <div class="col-md-12">
                        <form class="layui-form" id="courseForm">
                            <input type="hidden" name="teacher_id" id="teacher_id" th:value="${session.user.getId()}">
                            <div class="layui-form-item">
                                <label class="layui-form-label">课程名称</label>
                                <div class="layui-input-block">
                                    <input name="course_name" id="course_name" style="width: 1020px" class="layui-input" type="text" placeholder="请输入班级名称" autocomplete="off" lay-verify="title">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">教师名</label>
                                <div class="layui-input-block">
                                    <input name="teacher_name" id="teacher_name" style="width: 1020px" class="layui-input" type="text" placeholder="请输入教师名" autocomplete="off" lay-verify="required" lay-reqtext="教师名是必填项，岂能为空？">
                                </div>
                            </div>

<!--                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">验证邮箱</label>
                                    <div class="layui-input-inline">
                                        <input name="email" class="layui-input" type="text" autocomplete="off" lay-verify="email">
                                    </div>
                                </div>
                            </div>-->
                            <div class="layui-form-item layui-form-text">
                                <label class="layui-form-label">课程描述</label>
                                <div class="layui-input-block">
                                    <textarea class="layui-textarea" name="course_describe" id="course_describe" placeholder="请输入内容"></textarea>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="layui-btn" type="submit" lay-filter="demo1" lay-submit="" onclick="createCourse()">立即提交</button>
                                    <button class="layui-btn layui-btn-primary" type="reset">重置</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    <div th:replace="back/footer :: footer"></div>
</div>

<script>
    function createCourse() {
        $.post(
            "/teacher/createdCourse",
            $("#courseForm").serialize(),
            function (data) {
                if(data=="OK")
                {
                    alert("创建课程成功！");
                    window.location.href='/user/Course';
                }
                else {
                    alert("创建课程失败！");
                    window.location.reload();
                }
            }
        )
    }
</script>


<script th:src="@{/back/plugins/tagsinput/jquery.tagsinput.min.js}"></script>
<script th:src="@{/back/plugins/jquery-multi-select/jquery.quicksearch.js}"></script>

<script th:src="@{/back/plugins/mditor/js/mditor.min.js}"></script>
<script th:src="@{/back/plugins/multi-select/0.9.12/js/jquery.multi-select.min.js}"></script>
<script th:src="@{/back/plugins/select2/3.4.8/select2.min.js}"></script>
<script th:src="@{//cdn.bootcss.com/jquery-toggles/2.0.4/toggles.min.js}"></script>
<script th:src="@{/back/plugins/dropzone/4.3.0/min/dropzone.min.js}"></script>
<script th:src="@{/back/plugins/to-markdown/3.1.0/to-markdown.min.js}"></script>

<script th:src="@{/back/js/article.js}"></script>

<script th:src="@{/assets/js/jquery.min.js}"></script>
<script th:src="@{/back/js/bootstrap.js}"></script>
<script th:src="@{/back/js/sweetalert2.min.js}"></script>
<script th:src="@{/back/js/jquery.app.js}"></script>
<script th:src="@{/back/js/base.js}"></script>
</body>
</html>